Typing deep pattern-matching in presence of polymorphic variants

نویسنده

  • Jacques Garrigue
چکیده

Polymorphic variants are a well-known feature of the Objective Caml programming language, and they have turned popular since their introduction. They allow structural equality of algebraic type definitions, and code reuse through their polymorphism. Their typing and compilation have been studied in the past, and there are already detailed published works for both2),4). By their very nature, polymorphic variants depend on patternmatching to analyze their contents. However, only typing for shallow pattern-matching was studied in the past. In that case, checking exhaustiveness is trivial, and the natural typing rule guarantees it. Deep pattern-matching is more complex, as other constructors may appear nested in the same pattern-matching. Exhaustiveness check is available, but only after finishing type checking, while we would like to use it to define the typing of polymorphic variant patterns. We explain the tradeoffs, and define a type checking algorithm for pattern-matching containing polymorphic variants which is symmetric.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Simple Type Inference for Structural Polymorphism

We propose a new way to mix constrained types and type inference, where the interaction between the two is minimal. By using local constraints embedded in types, rather than the other way round, we obtain a system which keeps the usual structure of an Hindley-Milner type system. In practice, this means that it is easy to introduce local constraints in existing type inference algorithms. Eventho...

متن کامل

Constraint-Based Type Inference for Guarded Algebraic Data Types

Guarded algebraic data types subsume the concepts known in the literature as indexed types, guarded recursive datatype constructors, and first-class phantom types, and are closely related to inductive types. They have the distinguishing feature that, when typechecking a function defined by cases, every branch may be checked under different typing assumptions. This mechanism allows exploiting th...

متن کامل

Genotyping pattern of Staphylococcus aureus isolated from nasal carriers among health care workers in two hospitals (Imam Sajjad and Shahid Beheshti) in Yasuj city using coa-typing method.

Background and aim: Staphylococcus aureus can colonizes variety of body sites such as skin, coetaneous membrane and especially anterior nares.  The coagulase gene (coa) typing is a technique in which the organism is typed based on the polymorphic region of the coa gene. The aim of the present study was to determine the coa based typing of S. aureus isolates from health care workers in two teach...

متن کامل

Molecular Typing of Mycobacterium Tuberculosis Isolated from Iranian Patients Using Highly Abundant Polymorphic GC-Rich-Repetitive Sequence

Background: Tuberculosis (TB) with more than 10 million new cases per year and one of the top 10 causes of death worldwide, is still one of the most important global health problems. Also, multi drug-resistant tuberculosis (MDR) is a serious danger to public health. Understanding of the epidemiological pattern of mycobacterium tuberculosis (MTB), Estimates of recent transmission and recurrence ...

متن کامل

Tracing ambiguity in GADT type inference

GADTs, short for Generalized Algebraic DataTypes, extend usual algebraic datatypes with a form of dependent typing that has many useful applications, but raises serious issues for type inference. Pattern matching on GADTs introduces type equalities with limited scopes, which are a source of ambiguities that may destroy principal types—and must be resolved by type annotations. By tracing ambigui...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2004